<?php

	session_start();

	include('functions.php');
	
	$congress = obtenerCongress(getValor('idcongress'));

	$bgcolor = $congress['BACKGROUND_COLOR'];

?>

<?php

	$errors = array();
	$ispasswordsent = false;

	if (isset($_POST['sendmail'])) {
		
		$email = getValor('email');
		$confirm = getValor('confirm');
		$firstName = getValor('firstName');
		$lastName = getValor('lastName');
		$company = getValor('company');
		$subject = getValor('subject');
		$note = getValor('note');
		$fullNote = getValor('fullNote');
		
		if ($email == "") {
			array_push($errors, "The email cannot be empty");
		}

		if ($confirm == "") {
			array_push($errors, "The confirmation email cannot be empty");
		}

		if ($email != "" && $confirm != "" && $email != $confirm) {
			array_push($errors, "The email and confirmation email must be the same");
		}

		if ($firstName == "") {
			array_push($errors, "The first name cannot be empty");
		}
		
		if ($lastName == "") {
			array_push($errors, "The last name cannot be empty");
		}
		
		if ($company == "") {
			array_push($errors, "The company cannot be empty");
		}
		
		if ($subject == "") {
			array_push($errors, "The subject cannot be empty");
		}
		
		if ($note == "") {
			array_push($errors, "The note cannot be empty");
		}
		
		if ($fullNote == "") {
			array_push($errors, "The full note cannot be empty");
		}
		
		if (sizeof($errors) == 0) {
			$body = $firstName . " " . $lastName . " from " . $company . " has requested the password for the congress " .  $congress['NAME'] . "<br>";
			$body = $body . "Name: " . $firstName . " " . $lastName . "<br>";
			$body = $body . "Email: " . $email . "<br>";
			$body = $body . "Subject: " . $subject . "<br>";
			$body = $body . "Note: " . $note . "<br>";
			$body = $body . "Full Note: " . $fullNote . "<br>";
			
			sendMail($email, $congress['FORWARD_EMAIL'], "Password Recovery", $body);
			
			$success = "Your request has been sent. Please allow 24-48 hours for reply";
		}
		
	}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

	<title><?php echo $congress['NAME']; ?></title>

	<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="accordion/style.css" rel="stylesheet" type="text/css" media="screen" />

	<script src="accordion/accordian.pack.js" language="javascript" type="text/javascript">
	</script>

	<style>
		body {
			padding: 0px;
			margin: 0px;
		}
		
		.bodybg {
			background: <?php echo $bgcolor; ?>
			filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='<?php echo $bgcolor; ?>', endColorstr='#FFFFFF');
			background: -webkit-gradient(linear, left top, left bottom, from(<?php echo $bgcolor; ?>), to(#FFFFFF));
			background: -moz-linear-gradient(top,  <?php echo $bgcolor ?>,  #FFFFFF);
			width:100%;
			height: 600px;
		}
	</style>

</head>

<body>

	<div align="center" class="bodybg">

		<?php include('main_header.php'); ?>

		<div style="width: 880px; background-color: <?php echo $congress['PRIMARY_COLOR']; ?>; color: white; font-weight: bold;">
			<table width="860" style="margin-left:20px; margin-top: 10px;">
				<tr>
					<td>
						FORGOT YOUR PASSWORD
					</td>
				</tr>
			</table>
		</div>

		<div id="basic-accordian">
		
			<?php if (isset($success)) { include('success.php'); } ?>
		
			<form action="password_forgot.php" method="post">
				
				<input type="hidden" name="sendmail" value="sendmail" />
				<input type="hidden" name="idcongress" value="<?php echo getValor('idcongress') ?>" />
				
				<table bgcolor="#FFFFFF" width="100%" cellpadding="5">
					
					<?php if (sizeof($errors) > 0) { ?>
					
					<tr>
						<td>
							<?php include ('errors.php'); ?>
						</td>
					</tr>
					
					<?php } ?>
					
					<?php if ($ispasswordsent) { ?>
					
					<tr>
						<td>Password Sent Successfully</td>
					</tr>
					
					<?php } ?>
					
					<tr>
						<td align="center">
							<table cellpadding="6" >
								<tr>
									<td width="170">
										Email
									</td>
									<td>
										<input type="text" value="<?php echo getValor('email'); ?>" name="email" maxlength="50" style="width: 250px;" />
									</td>
								</tr>
								<tr>
									<td>
										Confirm Email
									</td>
									<td>
										<input type="text" value="<?php echo getValor('confirm'); ?>" name="confirm" maxlength="50" style="width: 250px;" />
									</td>
								</tr>
								<tr>
									<td>
										First Name
									</td>
									<td>
										<input type="text" value="<?php echo getValor('firstName'); ?>" name="firstName" maxlength="50" style="width: 250px;" />
									</td>
								</tr>
								<tr>
									<td>
										Last Name
									</td>
									<td>
										<input type="text" value="<?php echo getValor('lastName'); ?>" name="lastName" maxlength="50" style="width: 250px;" />
									</td>
								</tr>
								<tr>
									<td>
										Company
									</td>
									<td>
										<input type="text" value="<?php echo getValor('company'); ?>" name="company" maxlength="50" style="width: 250px;" />
									</td>
								</tr>
								<tr>
									<td>
										Subject 
									</td>
									<td>
										<input type="text" value="<?php echo getValor('subject'); ?>" name="subject" maxlength="50" style="width: 250px;"/>
									</td>
								</tr>
								<tr>
									<td>
										Note
									</td>
									<td>
										<input type="text" value="<?php echo getValor('note'); ?>" name="note" maxlength="50" style="width: 250px;"/>
									</td>
								</tr>
								<tr>
									<td>
										(Max: 300 Characters)
									</td>
									<td>
										<textarea cols="25" rows="5" name="fullNote"><?php echo getValor('fullNote'); ?></textarea>
									</td>
								</tr>
								<tr>
									<td>&nbsp;
										
									</td>
									<td>
										<input type="submit" value="Send" />
									</td>
								</tr>
								<tr>
									<td>&nbsp;
										
									</td>
									<td style="font-size: 9px;">
										Please use email that was used to register with the Congress. Please allow 24-48 hours for reply
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</form>
		</div>
		
	</div>

</body>
</html>
